Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 4x 4x 4x 4x 1x 3x 3x 4x 2x 1x | import { NextRequest, NextResponse } from "next/server";
import { runQuery } from "@/lib/neo4j";
import { requireAuth, isAuthError } from "@/lib/auth-guard";
export const dynamic = "force-dynamic";
/**
* DELETE /api/credentials/[id] — Remove a Verifiable Credential from Neo4j.
*
* Deletes the VerifiableCredential node and all its relationships.
*/
export async function DELETE(
_req: NextRequest,
{ params }: { params: Promise<{ id: string }> },
) {
const auth = await requireAuth();
Iif (isAuthError(auth)) return auth;
const { id } = await params;
if (!id) {
return NextResponse.json(
{ error: "Credential ID is required" },
{ status: 400 },
);
}
const result = await runQuery<{ deleted: number }>(
`MATCH (vc:VerifiableCredential { credentialId: $id })
DETACH DELETE vc
RETURN count(vc) AS deleted`,
{ id },
);
const deleted = result[0]?.deleted ?? 0;
if (deleted === 0) {
return NextResponse.json(
{ error: "Credential not found", id },
{ status: 404 },
);
}
return NextResponse.json({ status: "deleted", id });
}
|